rm(list = ls())
options(scipen = 999)
# Load the necessary libraries
library(Synth)
library(dplyr)
library(writexl)
# Load your panel data (replace 'your_data.csv' with your actual file name and path)
#data <- read.csv("data_constantusd.csv",sep=";") # BENCHMARK CURRENT USD
data <- read.csv("data_WB_constant_2015.csv",sep=";") # BENCHMARK CURRENT USD
#data <- read.csv("data_WB_constant_PPP.csv",sep=";")
#data <- read.csv("data_WB_PPA_actual.csv",sep=";")
#data <- read.csv("data_WB_PPA_constant.csv",sep=";")
#data <- read.csv("data_IMF_PPP_constant.csv",sep=";")
data$country_name <- as.character(data$country_name)
data$country_code <- as.character(data$country_code)
# Set the treated unit (country) index for which you want to estimate the treatment effect
treated_country <- 'Chile'  # Replace this with the index of the country you want to treat
# Identify the pre-treatment and post-treatment periods
pre_treatment_period <- c(1990, 2013)   # Replace with the years of your pre-treatment period
post_treatment_period <- c(2013, 2019)  # Replace with the years of your post-treatment period
# Create the outcome and covariates matrices
outcome <- data[data$country_name == treated_country, "gdp"]
covariate_names <- c(names(data)[4:12]) #all [4:12]
#covariate_names <- c(names(data)[4:6],names(data)[9:12]) #all [4:12]
covariate_names
data <- data %>%
mutate_at(c(all_of(covariate_names)), ~as.numeric(gsub(",", ".", .)))
covariates <- data %>% subset(country_name != treated_country) %>% select(all_of(covariate_names))
data$country_index = as.numeric(factor(data$country_name))
# Codigo_synthetic ----------------------------------------------
data.out.at11 <-
dataprep(data,
predictors = covariate_names,
dependent     = "gdp",
unit.variable = "country_index",
time.variable = "year",
unit.names.variable = "country_name",
treatment.identifier  = 6,
controls.identifier   = c(1:5,7:23),	# w/o China c(1:5,8:23), ;w/o c(1:5,7,8,10:23) CR; w/o  UR c(1:5,7:22)
time.predictors.prior = c(1990:2013),
time.optimize.ssr     = c(1990:2013),	#2013		#2006 1st year Bachelet placebo
time.plot             = c(1990:2019))
synth.out.at11 <- synth(data.out.at11)
synth.tables.at11   <- synth.tab(
dataprep.res = data.out.at11,
synth.res    = synth.out.at11)
synth.tables.at11
# Pesos países ----------------
w.at11 <- as.data.frame(synth.tables.at11$tab.w)
w.at11
w_suficiente <- w.at11 %>% subset(w.weights > 0.001)
w_suficiente
# Importancia relativa variables ----------------
v.at11 <- as.data.frame(synth.tables.at11$tab.v)
v.at11
v_suficiente <- v.at11 %>% subset(v.weights > 0.001)
v_suficiente
#-----Matching treated vs Synth--------
matching <- as.data.frame(synth.tables.at11$tab.pred)
matching
# Crear un gráfico para visualizar los resultados --------
path.plot(
dataprep.res = data.out.at11, # los datos preparados
synth.res = synth.out.at11,       # los resultados de la función synth()
Main = "Chile's GDP Per Capita",    # el título principal del gráfico
Ylab = "GDP per capita",         # la etiqueta del eje y
Xlab = "Year",                    # la etiqueta del eje x
Legend = c("Chile", "Synthetic Chile"), # la leyenda
# CI = TRUE                        # si quieres incluir un intervalo de confianza
)
# Crear un gráfico para visualizar los resultados --------
path.plot(
dataprep.res = data.out.at11, # los datos preparados
synth.res = synth.out.at11,       # los resultados de la función synth()
Main = "Chile's GDP Per Capita",    # el título principal del gráfico
Ylab = "GDP per capita",         # la etiqueta del eje y
Xlab = "Year",                    # la etiqueta del eje x
Legend = c("Chile", "Synthetic Chile"), # la leyenda
# CI = TRUE                        # si quieres incluir un intervalo de confianza
)
# Agrega una línea vertical en el año XXX (color rojo)
abline(v = 2014, col = "red")
View(data)
#This R code replicate the results in Toni et al 2024
#Policy Changes and Growth Slowdown: Assessing the Lost Decade of the Latin American Miracle
rm(list = ls())
options(scipen = 999)
# Loading  necessary libraries
library(Synth)
library(dplyr)
library(writexl)
# Loading panel data
data <- read.csv("data_WB_constant_2015.csv",sep=";") # BENCHMARK RESULTS CONSTANT 2015 USD
#data <- read.csv("data_WB_constant_PPP.csv",sep=";") # constant PPP.
#data <- read.csv("data_WB_current_USD.csv",sep=";") #  current USD
data$country_name <- as.character(data$country_name)
data$country_code <- as.character(data$country_code)
# Set the treated unit (country) index for which you want to estimate the treatment effect
treated_country <- 'Chile'  # Replace this with the index of the country you want to treat
# Identify the pre-treatment and post-treatment periods (intervention year 2014)
pre_treatment_period <- c(1990, 2013)   # Replace with the years of your pre-treatment period
post_treatment_period <- c(2013, 2019)  # Replace with the years of your post-treatment period
# Create the outcome and covariates matrices
outcome <- data[data$country_name == treated_country, "gdp"]
covariate_names <- c(names(data)[4:12]) #all [4:12]
#covariate_names <- c(names(data)[4:6],names(data)[9:12]) #all [4:12]
covariate_names
data <- data %>%
mutate_at(c(all_of(covariate_names)), ~as.numeric(gsub(",", ".", .)))
covariates <- data %>% subset(country_name != treated_country) %>% select(all_of(covariate_names))
data$country_index = as.numeric(factor(data$country_name))
# Codigo_synthetic ----------------------------------------------
data.out.at11 <-
dataprep(data,
predictors = covariate_names,
dependent     = "gdp",
unit.variable = "country_index",
time.variable = "year",
unit.names.variable = "country_name",
treatment.identifier  = 6,
controls.identifier   = c(1:5,7:23),
time.predictors.prior = c(1990:2013),
time.optimize.ssr     = c(1990:2013), #intervention set to 2014
time.plot             = c(1990:2019))
#All Countries (GROUP 2) = c(1:5,7:23)
#GROUP 1 = c(1,3,4,8:13,15:17,23) LATIN NEIGHBOURS
synth.out.at11 <- synth(data.out.at11)
synth.tables.at11   <- synth.tab(
dataprep.res = data.out.at11,
synth.res    = synth.out.at11)
synth.tables.at11
# Coutnry Weights ----------------
w.at11 <- as.data.frame(synth.tables.at11$tab.w)
w.at11
# # Save results excel
# file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/all_countries_weights.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
# write_xlsx(w.at11, path = file_path)
# # Print a message to confirm the file has been saved
# cat("Data has been saved to", file_path, "\n")
w_suficiente <- w.at11 %>% subset(w.weights > 0.001)
w_suficiente
# # Save results excel
#file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/weights_country_constantUSD.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
# write_xlsx(w_suficiente, path = file_path)
# # Print a message to confirm the file has been saved
# cat("Data has been saved to", file_path, "\n")
# Variables weights ----------------
v.at11 <- as.data.frame(synth.tables.at11$tab.v)
v.at11
v_suficiente <- v.at11 %>% subset(v.weights > 0.001)
v_suficiente
# # Save results excel
# file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/weights_variables.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
# write_xlsx(v.at11, path = file_path)
# # Print a message to confirm the file has been saved
# cat("Data has been saved to", file_path, "\n")
#-----Matching treated vs Synth--------
matching <- as.data.frame(synth.tables.at11$tab.pred)
matching
# # Save results excel
#file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/results_group1.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
#write_xlsx(matching, path = file_path)
# # Print a message to confirm the file has been saved
#cat("Data has been saved to", file_path, "\n")
# Creating plot to visualize results --------
path.plot(
dataprep.res = data.out.at11, # los datos preparados
synth.res = synth.out.at11,       # los resultados de la función synth()
Main = "Chile's GDP Per Capita",    # el título principal del gráfico
Ylab = "GDP per capita",         # la etiqueta del eje y
Xlab = "Year",                    # la etiqueta del eje x
Legend = c("Chile", "Synthetic Chile"), # la leyenda
# CI = TRUE                        # si quieres incluir un intervalo de confianza
)
# Vertical line on intervention year (color rojo)
abline(v = 2014, col = "red")
data_synth_chile <- data.out.at11$Y0plot%*%synth.out.at11$solution.w
data_synth_chile <- cbind.data.frame(country_name = 'Synthetic Chile',
year = row.names(data_synth_chile),
gdp = data_synth_chile)
data_synth_chile <- data_synth_chile %>% rename(gdp = w.weight)
data_synth_chile
variable_dependiente_paises <- rbind.data.frame(variable_dependiente_paises, data_synth_chile)
# SC validación cruzada ----------------------------------------------
num_iters <- 100  # Número de iteraciones para la validación cruzada
# Guarda los resultados
results <- list()
#install.packages("pbkrtest")
#install.packages("car")
library(car)
model <- lm(gdp ~ ., data=data %>% select(c(all_of(c('gdp', names(data)[c(5:13)]))))) #Check 5:13 5,7:13
vif_values <- vif(model)
print(vif_values)
input_dataprep_para_SC <-
dataprep(data,
predictors = covariate_names,
dependent     = "gdp",
unit.variable = "country_index",
time.variable = "year",
unit.names.variable = "country_name",
treatment.identifier  = 6,
controls.identifier   = c(1:5,7:23), #all the 98 regions from the donor pool
time.predictors.prior = c(1990:2013),	#testing 2014
time.optimize.ssr     = c(1990:2013),
time.plot             = c(1990:2019))
modelo.SC <- synth(input_dataprep_para_SC)
# Pesos países
w.at11 <- as.data.frame(tablas_resultados.SC$tab.w)
w.at11
tablas_resultados.SC   <- synth.tab(
dataprep.res = input_dataprep_para_SC,
synth.res    = modelo.SC)
w_suficiente <- w.at11 %>% subset(w.weights > 0.001)
# Importancia relativa variables
v.at11 <- as.data.frame(tablas_resultados.SC$tab.v)
v.at11
v_suficiente <- v.at11 %>% subset(v.weights > 0.001)
# Crear un gráfico para visualizar los resultados
path.plot(
dataprep.res = input_dataprep_para_SC, # los datos preparados
synth.res = modelo.SC,       # los resultados de la función synth()
Main = "GDP Per Capita Results",    # el título principal del gráfico
Ylab = "GDP Per Capita",         # la etiqueta del eje y
Xlab = "Year",                    # la etiqueta del eje x
Legend = c("Chile", "Synthetic Chile"), # la leyenda
# CI = TRUE                        # si quieres incluir un intervalo de confianza
)
# Importancia relativa variables
v.at11 <- as.data.frame(tablas_resultados.SC$tab.v)
v.at11
v_suficiente <- v.at11 %>% subset(v.weights > 0.001)
# Crear un gráfico para visualizar los resultados
path.plot(
dataprep.res = input_dataprep_para_SC, # los datos preparados
synth.res = modelo.SC,       # los resultados de la función synth()
Main = "GDP Per Capita Results",    # el título principal del gráfico
Ylab = "GDP Per Capita",         # la etiqueta del eje y
Xlab = "Year",                    # la etiqueta del eje x
Legend = c("Chile", "Synthetic Chile"), # la leyenda
# CI = TRUE                        # si quieres incluir un intervalo de confianza
)
# Crear un gráfico de barras para los pesos
barplot(w.at11$w.weights, main = "Pesos de las unidades de control", xlab = "Unidades de control", ylab = "Peso")
# Paises con pesos positivos
paises_peso_positivo <- w.at11 %>% subset(w.weights >= 0.001) %>% select(unit.names, w.weights)
variable_dependiente_paises <- data %>% select(country_name, year, gdp)
data_synth_chile <- input_dataprep_para_SC$Y1plot
data_synth_chile <- cbind.data.frame(country_name = 'Synthetic Chile',
year = row.names(data_synth_chile),
gdp = data_synth_chile)
data_synth_chile <- data_synth_chile %>% rename(gdp = `6`)
variable_dependiente_paises <- rbind.data.frame(variable_dependiente_paises, data_synth_chile)
chile_sintetico <- (input_dataprep_para_SC$Y0plot %*% modelo.SC$solution.w)
datos_chile_original <- data %>% subset(country_name == 'Chile') %>% select(year, gdp)
# Chequeando escalas
data_chile_org_y_synth <- cbind.data.frame(chile_sintetico,
datos_chile_original)
# GAP
gaps <- input_dataprep_para_SC$Y1plot - (input_dataprep_para_SC$Y0plot %*% modelo.SC$solution.w)
gaps[1:3, 1]
library(ggplot2)
data_total <- variable_dependiente_paises
# Convertir las columnas a los tipos de datos correctos
chile_sintetico <- (input_dataprep_para_SC$Y0plot %*% modelo.SC$solution.w)
chile_sintetico <- cbind.data.frame(year = row.names(chile_sintetico) ,
gdp = chile_sintetico)
#row.names(chile_sintetico) = NULL
names(chile_sintetico) <- c('year', 'gdp')
data_chile_org_y_synth <- rbind.data.frame(cbind(chile_sintetico, pais = 'Synthetic Chile'),
cbind(datos_chile_original, pais = 'Chile'))
data_chile_org_y_synth$year <- as.numeric(as.character(data_chile_org_y_synth$year))
# data_total <- data_total %>% subset(country_name %in% c('Chile', 'Synthetic Chile', as.character(paises_peso_positivo$unit.names)))
# data_chile_org_y_synth <- data_chile_org_y_synth %>% subset(pais %in% c('Chile', 'Synthetic Chile'))#, as.character(paises_peso_positivo$unit.names)))
data_chile_org_y_synth$gdp <- as.numeric(data_chile_org_y_synth$gdp)
# Generar el gráfico
ggplot(data_chile_org_y_synth, aes(x = year, y = gdp, color = pais)) +
geom_line(aes(alpha = 1)) +
# geom_line(aes(alpha = ifelse(pais %in% c("Chile", "Synthetic Chile"), 1, 0.3))) +
scale_alpha(guide = 'none') +
labs(x = "Year", y = "GDP Per Capita", color = "Label") +
theme_minimal() +
geom_vline(xintercept = 2013, linetype = 'dashed', colour = 'gray')
# Placebo tests -----------------------------------------------------------
#library(remotes)
#install_github("bcastanho/SCtools")
library(SCtools)
tdf <- generate.placebos(input_dataprep_para_SC,modelo.SC,
strategy = 'multicore')
p <- plot_placebos(tdf,discard.extreme=TRUE, mspe.limit=10, xlab='Year')
p
#Policy Changes and Growth Slowdown: Assessing the Lost Decade of the Latin American Miracle
rm(list = ls())
options(scipen = 999)
# Loading  necessary libraries
library(Synth)
library(dplyr)
library(writexl)
# Loading panel data
data <- read.csv("data_WB_constant_2015.csv",sep=";") # BENCHMARK RESULTS CONSTANT 2015 USD
#data <- read.csv("data_WB_constant_PPP.csv",sep=";") # constant PPP.
#data <- read.csv("data_WB_current_USD.csv",sep=";") #  current USD
data$country_name <- as.character(data$country_name)
data$country_code <- as.character(data$country_code)
# Set the treated unit (country) index for which you want to estimate the treatment effect
treated_country <- 'Chile'  # Replace this with the index of the country you want to treat
# Identify the pre-treatment and post-treatment periods (intervention year 2014)
pre_treatment_period <- c(1990, 2005)   # Replace with the years of your pre-treatment period (2013)
post_treatment_period <- c(2005, 2019)  # Replace with the years of your post-treatment period
# Create the outcome and covariates matrices
outcome <- data[data$country_name == treated_country, "gdp"]
covariate_names <- c(names(data)[4:12]) #all [4:12]
#covariate_names <- c(names(data)[4:6],names(data)[9:12]) #all [4:12]
covariate_names
data <- data %>%
mutate_at(c(all_of(covariate_names)), ~as.numeric(gsub(",", ".", .)))
covariates <- data %>% subset(country_name != treated_country) %>% select(all_of(covariate_names))
data$country_index = as.numeric(factor(data$country_name))
# Codigo_synthetic ----------------------------------------------
data.out.at11 <-
dataprep(data,
predictors = covariate_names,
dependent     = "gdp",
unit.variable = "country_index",
time.variable = "year",
unit.names.variable = "country_name",
treatment.identifier  = 6,
controls.identifier   = c(1:5,7:23),
time.predictors.prior = c(1990:2005),
time.optimize.ssr     = c(1990:2005), #intervention set to 2014 c(1990:2013)
time.plot             = c(1990:2019))
#All Countries (GROUP 2) = c(1:5,7:23)
#GROUP 1 = c(1,3,4,8:13,15:17,23) LATIN NEIGHBOURS
synth.out.at11 <- synth(data.out.at11)
synth.tables.at11   <- synth.tab(
dataprep.res = data.out.at11,
synth.res    = synth.out.at11)
synth.tables.at11
# Coutnry Weights ----------------
w.at11 <- as.data.frame(synth.tables.at11$tab.w)
w.at11
# # Save results excel
# file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/all_countries_weights.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
# write_xlsx(w.at11, path = file_path)
# # Print a message to confirm the file has been saved
# cat("Data has been saved to", file_path, "\n")
w_suficiente <- w.at11 %>% subset(w.weights > 0.001)
w_suficiente
# # Save results excel
#file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/weights_country_constantUSD.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
# write_xlsx(w_suficiente, path = file_path)
# # Print a message to confirm the file has been saved
# cat("Data has been saved to", file_path, "\n")
# Variables weights ----------------
v.at11 <- as.data.frame(synth.tables.at11$tab.v)
v.at11
v_suficiente <- v.at11 %>% subset(v.weights > 0.001)
v_suficiente
# # Save results excel
# file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/weights_variables.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
# write_xlsx(v.at11, path = file_path)
# # Print a message to confirm the file has been saved
# cat("Data has been saved to", file_path, "\n")
#-----Matching treated vs Synth--------
matching <- as.data.frame(synth.tables.at11$tab.pred)
matching
# # Save results excel
#file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/results_group1.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
#write_xlsx(matching, path = file_path)
# # Print a message to confirm the file has been saved
#cat("Data has been saved to", file_path, "\n")
# Creating plot to visualize results --------
path.plot(
dataprep.res = data.out.at11, # los datos preparados
synth.res = synth.out.at11,       # los resultados de la función synth()
Main = "Chile's GDP Per Capita",    # el título principal del gráfico
Ylab = "GDP per capita",         # la etiqueta del eje y
Xlab = "Year",                    # la etiqueta del eje x
Legend = c("Chile", "Synthetic Chile"), # la leyenda
# CI = TRUE                        # si quieres incluir un intervalo de confianza
)
#This R code replicate the results in Toni, Paniagua and Órdenes 2024
#Policy Changes and Growth Slowdown: Assessing the Lost Decade of the Latin American Miracle
rm(list = ls())
options(scipen = 999)
# Loading  necessary libraries
library(Synth)
library(dplyr)
library(writexl)
# Loading panel data
data <- read.csv("data_WB_constant_2015.csv",sep=";") # BENCHMARK RESULTS CONSTANT 2015 USD
#data <- read.csv("data_WB_constant_PPP.csv",sep=";") # constant PPP.
#data <- read.csv("data_WB_current_USD.csv",sep=";") #  current USD
data$country_name <- as.character(data$country_name)
data$country_code <- as.character(data$country_code)
# Set the treated unit (country) index for which you want to estimate the treatment effect
treated_country <- 'Chile'  # Replace this with the index of the country you want to treat
# Identify the pre-treatment and post-treatment periods (intervention year 2014)
pre_treatment_period <- c(1990, 2013)
post_treatment_period <- c(2013, 2019)
# Create the outcome and covariates matrices
outcome <- data[data$country_name == treated_country, "gdp"]
covariate_names <- c(names(data)[4:12]) #all [4:12]
covariate_names
data <- data %>%
mutate_at(c(all_of(covariate_names)), ~as.numeric(gsub(",", ".", .)))
covariates <- data %>% subset(country_name != treated_country) %>% select(all_of(covariate_names))
data$country_index = as.numeric(factor(data$country_name))
# Synthetic_Estimation ----------------------------------------------
data.out.at11 <-
dataprep(data,
predictors = covariate_names,
dependent     = "gdp",
unit.variable = "country_index",
time.variable = "year",
unit.names.variable = "country_name",
treatment.identifier  = 6,
controls.identifier   = c(1:5,7:23),
time.predictors.prior = c(1990:2013),
time.optimize.ssr     = c(1990:2013), #intervention set to 2014
time.plot             = c(1990:2019))
#All Countries (GROUP 2) = c(1:5,7:23)
#GROUP 1 = c(1,3,4,8:13,15:17,23) LATIN NEIGHBOURS
synth.out.at11 <- synth(data.out.at11)
synth.tables.at11   <- synth.tab(
dataprep.res = data.out.at11,
synth.res    = synth.out.at11)
synth.tables.at11
# Coutnry Weights ----------------
w.at11 <- as.data.frame(synth.tables.at11$tab.w)
w.at11
# # Save results excel
# file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/all_countries_weights.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
# write_xlsx(w.at11, path = file_path)
# # Print a message to confirm the file has been saved
# cat("Data has been saved to", file_path, "\n")
w_suficiente <- w.at11 %>% subset(w.weights > 0.001)
w_suficiente
# # Save results excel
#file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/weights_country_constantUSD.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
# write_xlsx(w_suficiente, path = file_path)
# # Print a message to confirm the file has been saved
# cat("Data has been saved to", file_path, "\n")
# Variables weights ----------------
v.at11 <- as.data.frame(synth.tables.at11$tab.v)
v.at11
v_suficiente <- v.at11 %>% subset(v.weights > 0.001)
v_suficiente
# # Save results excel
# file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/weights_variables.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
# write_xlsx(v.at11, path = file_path)
# # Print a message to confirm the file has been saved
# cat("Data has been saved to", file_path, "\n")
#-----Matching treated vs Synth--------
matching <- as.data.frame(synth.tables.at11$tab.pred)
matching
# # Save results excel
#file_path <- "/Users/emilianotoni/Desktop/Synth_Faro_CODES/R_CODES/results_group2.xlsx"
# # Use the write_xlsx function to save the data frame to an Excel file
#write_xlsx(matching, path = file_path)
# # Print a message to confirm the file has been saved
#cat("Data has been saved to", file_path, "\n")
# Creating plot to visualize results --------
path.plot(
dataprep.res = data.out.at11, # los datos preparados
synth.res = synth.out.at11,       # los resultados de la función synth()
Main = "Chile's GDP Per Capita",    # el título principal del gráfico
Ylab = "GDP per capita",         # la etiqueta del eje y
Xlab = "Year",                    # la etiqueta del eje x
Legend = c("Chile", "Synthetic Chile"), # la leyenda
# CI = TRUE                        # si quieres incluir un intervalo de confianza
)
# Vertical line on intervention year (color rojo)
abline(v = 2014, col = "red")
# Generating vector with values for synthetic Chile--------------------------------
data_synth_chile <- data.out.at11$Y0plot%*%synth.out.at11$solution.w
data_synth_chile <- cbind.data.frame(country_name = 'Synthetic Chile',
year = row.names(data_synth_chile),
gdp = data_synth_chile)
data_synth_chile <- data_synth_chile %>% rename(gdp = w.weight)
data_synth_chile
